/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.imenu.ejb;

import com.imenu.entity.ImenuUser;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Yunzi
 */
@Stateless
public class ImenuUserFacade extends AbstractFacade<ImenuUser> {

    @PersistenceContext(unitName = "iMenuPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public ImenuUserFacade() {
        super(ImenuUser.class);
    }

    public ImenuUser findByUserName(String username) {
        System.out.println("ImenuUserFacade.findByUserName() username = "+username);
        Query query = em.createNamedQuery("ImenuUser.findByUsername");
        query.setParameter("username", username);
        return (ImenuUser) query.getSingleResult();
    }
}
